package com.mi.million.module.system.controller;

import com.mi.million.module.system.service.SystemService;
import com.mi.million.mybatis.entity.SysMenu;
import com.mi.rule.resource.ResC;
import com.mi.rule.resource.ResM;
import com.mi.rule.util.project.SRS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ResC(value = "菜单管理", parent = "系统配置")
@RestController
@RequestMapping("/system/menu")
public class MenuController {
    @Autowired
    SystemService systemService;


    @ResM("添加数据")
    @RequestMapping({"/insert"})
    public SRS insert(@RequestBody SysMenu menu) {
        return systemService.insertMenu(menu);
    }


    @ResM("删除数据")
    @RequestMapping({"/delete"})
    public SRS delete(@RequestBody Object[] ids) {
        return systemService.deleteMenu(ids);
    }


    @ResM("修改数据")
    @RequestMapping({"/update"})
    public SRS update(@RequestBody SysMenu menu) {
        return systemService.updateMenu(menu);
    }


    @ResM("分页查询")
    @RequestMapping("/page")
    public SRS page(@RequestBody SRS param) {
        return systemService.pageMenu(param);
    }


    @ResM("列表查询")
    @RequestMapping({"/list"})
    public SRS list(@RequestBody SRS param) {
        return systemService.listMenu(param);
    }

    @ResM("全部菜单")
    @RequestMapping({"/all"})
    public SRS all() {
        return SRS.bySuccess(systemService.menus());
    }

    @ResM("详情查询")
    @RequestMapping("/info")
    public SRS one(@RequestBody SRS param) {
        return systemService.infoMenu(param);
    }

    @ResM("提交前端路由数据")
    @RequestMapping("/submitMenu")
    public SRS refreshMenu(@RequestBody SysMenu[] resources) {
        return systemService.refreshMenu(resources);
    }
}
